MyDesktop.BeautyRss = Ext.extend(Ext.app.Module, {
	id:'beauty-rss',
    init : function(){
        this.launcher = {
            text: 'Rss 阅读器',
            iconCls:'bogus',
            handler : this.createWindow,
            scope: this
        }
    },

    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('beauty-rss');
	    if(!win) {    
	        win = desktop.createWindow({
	        id: '6',
	        title:'rss 阅读器',
	        layout:'border',
	        width:640,
	        height:480,
	        items: [{
			    title: 'Footer',
			    region: 'south',
			    height: 150,
			    minSize: 75,
			    maxSize: 250,
			    cmargins: '5 0 0 0'
			},{
			    collapsible: false,
			    region:'center',
			    margins: '5 0 0 0',
			    id:'rss-tab-panel',
				//xtype:'gridpanel',
				/*minTabWidth:115,
				enableTabScroll:true,
				defaults:{autoScroll:true},
				activeTab:0,
				resizeTabs:true,
				tabWidth:135*/
				items:
					new Ext.grid.GridPanel({
						border:false,
						ds:new Ext.data.Store({
							url:ServerUrl+'rss/ParseRssUrl',
							autoLoad:true, 
							reader: new Ext.data.JsonReader({
								root:'rss'
							}, [
								{name:'title'},
								{name:'link'},
								{name:'description'},	
								{name:'pubdate'}
							])
						}),
						cm: new Ext.grid.ColumnModel([
                        	new Ext.grid.RowNumberer(),
                        		{header: "标题", width: 120, sortable: true, dataIndex: 'title'},
                        		{header: "时间", width: 70, sortable: true, dataIndex: 'pubdate'}
                    	]),                       
						viewConfig: {
                        	forceFit:true
                    	}
					})
	       },{
			    title: '我的rss',
			    region:'west',
			    margins: '5 0 0 0',
			    cmargins: '5 5 0 0',
			    width: 175,
			    minSize: 100,
			    maxSize: 250,
				items:
					new Ext.tree.TreePanel({
						loader:new Ext.tree.TreeLoader({
							dataUrl:ServerUrl+'rss/getRssTree',
						}),							
						root: new Ext.tree.AsyncTreeNode({
							nodeType:'async',
	             			id:'8',
							text:'我的Rss源',
	             			draggable:false,
							expanded:true
	             		}),
						autoScroll:true,
						region : 'west',
						width : 200,
						rootVisible:true,
						tbar:[{
	            	 		text:'添加',
	            	 		id:'AddRss',
	            	 		tooltip:'添加Rss',
	                        iconCls:'rename',
	            	 		handler:function(){
	            	 			Ext.Msg.prompt('添加Rss','请输入Rss源',function(btn,text){
	                            	if(btn == 'ok' && text) {
	                            		Ext.Ajax.request({
		                            		url:ServerUrl+'rss/ParseRssUrl',
											method:'POST',
											params: {url : text},	
											success:function(response){
												//var r = Ext.util.JSON.decode(response.responseText);
											}	
		                            	});
	                            		}
	                            	},this, false, '');
	            	 			}	
	            	 		},'-',{
	            	 		text:'remove',
	            	 		id:'DeleteRss',
	            	 		tooltip:'remove a file',
            	 		}],
						listeners:{
							'click':function(node,e) {
								var url = node.attributes.url;
								Ext.Ajax.request({
									url:ServerUrl+'rss/ParseRssUrl',
									success:function(response) {
											
									}
								});
								//alert(url);
								/*if(url) {
									var tab = Ext.getCmp('rss-tab-panel');
            	 					tab.add({
					            		title: node.attributes.text,
					            		iconCls: 'tabs',
					            		html: 'Tab Body<br/><br>',
					            		closable:true
            	 					});
            	 					tab.setActiveTab();
								}*/
	
							}		  
						}


					})
			}]
         });

        win.show();
		if(win) {
			updateAppStatues(win.id,'on');
		}
        }
    }
});
